package com.eshop.we.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.eshop.we.account.api.AccountService;
import com.eshop.we.account.entity.Account;
import com.eshop.we.accountdetail.dto.AccountDetailDto;
import com.eshop.we.mapper.AccountMapper;
import com.eshop.we.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;


/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author anonymity
 * @since 2018-07-04
 */
@Service(interfaceClass = AccountService.class)
@Component
public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> implements AccountService {

    @Override
    public Page selectAccountDetailPage(Page<AccountDetailDto> page, String name, String mobile, String startDate, String endDate) {
        Long start=null;
        Long end=null;
        try{
             start= startDate!=null? DateUtil.str2Date(startDate+" 00:00:00").getTime():null;
             end= endDate!=null?DateUtil.str2Date(endDate+" 23:59:59").getTime():null;
        }catch (Exception e){
            e.printStackTrace();
        }
        List<AccountDetailDto> list=baseMapper.selectAccountPage(page,name,mobile,start,end);
        page.setRecords(list);
        return page;
    }
}
